import { execSync } from 'child_process';
import path from 'path';
import packages from '../packages/metadata/packages';

execSync('pnpm run build', { stdio: 'inherit' });

execSync('npm config set registry=https://registry.npmjs.org', { stdio: 'inherit' });
const command = 'npm publish --access public';

// @ts-ignore
for (const { name } of packages.default) {
  execSync(command, { stdio: 'inherit', cwd: path.join('packages', name, 'dist') });
}
execSync('npm config set registry=https://registry.npmmirror.com', { stdio: 'inherit' });
